﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Web_Main.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="Hotel.Models.Entity" %>
<%@ Import Namespace="Resources" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Room
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%--<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>--%>
    <%List<Floor> lf = (List<Floor>)ViewData["ListFloor"];
      List<RoomType> lrt = (List<RoomType>)ViewData["ListRoomType"];
      List<Room> lr = (List<Room>)ViewData["ListRoom"];
    %>
    <div id="submenu">
        <span class="sbla" id="sblinfo"></span><a class="sba" href="javascript:RoomTab.open('info');"
            id="rt_info">
            <% = Resource.TheStatusOfRooms%></a><span class="sbra" id="sbrinfo"></span>
        <span class="sbli" id="sblprice"></span><a class="sbi" href="javascript:RoomTab.open('price');"
            id="rt_price">
            <% = Resource.RoomPrice%></a><span class="sbri" id="sbrprice"></span> <span class="sbli"
                id="sblsetprice"></span><a class="sbi" href="javascript:RoomTab.open('setprice');"
                    id="rt_setprice">
                    <% = Resource.SetupPrice%></a><span class="sbri" id="sbrsetprice"></span></div>
    <div id="tab_room_content">
        <div id="roomtab_info_content">
            <div class="box ttb">
                <h1>
                    <% = Resource.SortingRoom%></h1>
            </div>
            <div class="box ctb">
                <div class="l3b b14">
                    Thông tin lầu: <span class="lr"><span><a href="#" id="addfloor" class="addroom" data-reveal-id="addFloor">
                        <div class="icAdd">
                        </div>
                        THÊM LẦU</a></span></span></div>
                <div id="addFloor" class="reveal-modal" data-animation="none" data-animationspeed="10"
                    data-closeonbackgroundclick="true" data-dismissmodalclass="close-reveal-modal">
                    <div class="reveal-modal-title">
                        <span>THÊM LẦU</span></div>
                    <div class="reveal-modal-content">
                        <table>
                            <tr>
                                <td width="100px">
                                    Tên lầu:
                                </td>
                                <td>
                                    <input type="text" name="txtFloorName" id="txtFloorName" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <button onclick="AddFloor();">
                                        Thêm</button>
                                    <button class="close-reveal-modal">
                                        Hủy</button>
                                </td>
                            </tr>
                        </table>
                        <a class="close-reveal-modal close-reveal">
                            <img src="/Content/images/exit.png" title="exit" alt="exit" /></a>
                    </div>
                    <label id="lblAddFloorStatus" style="color: red;"></label>
                </div>
                <div class="clear">
                </div>
                <div class="floorlist" id="floorlist">
                    <%if (lf != null)
                      {
                          foreach (Floor floor in lf)
                          {%>
                    <div class="rp floora" id="Div1">
                        <label class="lblfloor" id="lblfloor<%=floor.PkFloorId %>">
                            <%=floor.Name %></label>
                        <span class="boxfname" style="display: none;" id="boxfname<%=floor.PkFloorId %>">
                            <input type="text" title="7400" maxlength="100" class="txtfname" id="txtfname<%=floor.PkFloorId %>"
                                value="<%=floor.Name %>" style="float: left; width: 90px" onblur="EditFloor('<%=floor.PkFloorId %>')" /></span>
                        <a id="<%=floor.PkFloorId %>">Xóa</a><a class="spr">|</a>
                        <%--<a class="editFloor" id="fname<%=floor.PkFloorId %>">Sửa</a>--%>
                        <a onclick="editFloor('<%=floor.PkFloorId %>')">Sửa</a>
                    </div>
                    <%}

                      } %>
                </div>
                <div id="notificationadd" class="reveal-modal" data-animation="none" data-animationspeed="10"
                    data-closeonbackgroundclick="true" data-dismissmodalclass="close-reveal-modal">
                    <div class="reveal-modal-title">
                        <span>Thông báo</span></div>
                    <div class="reveal-modal-content">
                        <p id="messagetitle">
                        </p>
                        <br />
                        <button class="close-reveal-modal">
                            Đóng</button>
                        <a class="close-reveal-modal close-reveal">
                            <img src="/Content/images/exit.png" title="exit" alt="exit" /></a>
                    </div>
                </div>
                <div style="display: none;">
                    <a data-reveal-id="notificationadd" id="amessage">inline</a>
                </div>
                <div class="padbt10 clear">
                </div>
                <div class="l3b b14">
                    Phân loại phòng: <span class="lr"><span><a href="javascript:;" id="addfRoomtype"
                        data-reveal-id="addRoomType" class="addroom">
                        <div class="icAdd">
                        </div>
                        THÊM MỚI</a></span></span></div>
                <div id="addRoomType" class="reveal-modal" data-animation="none" data-animationspeed="10"
                    data-closeonbackgroundclick="true" data-dismissmodalclass="close-reveal-modal">
                    <div class="reveal-modal-title">
                        <span>THÊM LOẠI PHÒNG</span></div>
                    <div class="reveal-modal-content">
                        <table>
                            <tr>
                                <td width="100px">
                                    Tên loại phòng:
                                </td>
                                <td>
                                    <input type="text" name="txtRoomTypeName" id="txtRoomTypeName" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <button onclick="AddRoomType();">
                                        Thêm</button>
                                    <button class="close-reveal-modal">
                                        Hủy</button>
                                </td>
                            </tr>
                        </table>
                        <a class="close-reveal-modal close-reveal">
                            <img src="/Content/images/exit.png" title="exit" alt="exit" /></a>
                    </div>
                    <label id="lblAddRoomTypeStatus" style="color: red;"></label>
                </div>
                <div class="clear">
                </div>
                <div class="roomgrouplist" id="roomgrouplist">
                    <%if (lrt != null && lrt.Count > 0)
                      {
                          foreach (RoomType rt in lrt)
                          {%>
                    <div class="rp floora" id="gdiv2330">
                        <label class="lblgname" id="lblRoomTypeName<%=rt.RoomTypeId %>">
                            <%=rt.RoomTypeName %></label>
                        <span class="boxgname" style="display: none;" id="boxgname<%=rt.RoomTypeId %>">
                            <input type="text" maxlength="100" class="txtRoomTypeName" id="txtRoomTypeName<%=rt.RoomTypeId %>"
                                style="float: left; width: 90px" value="<%=rt.RoomTypeName %>"></span> <a onclick="">
                                    Xóa</a><a class="spr">|</a> <a onclick="editRoomType('<%=rt.RoomTypeId %>')">Sửa</a>
                    </div>
                    <%}
                      } %>
                </div>
            </div>
            <div class="box ttb">
                <h1>
                    <% = Resource.RoomInfo%></h1>
                <span><a href="javascript:;" id="addroom" class="addroom" data-reveal-id="addRoom">
                    <div class="icAdd">
                    </div>
                    THÊM PHÒNG</a></span></div>
            <div id="addRoom" class="reveal-modal" data-animation="none" data-animationspeed="10"
                data-closeonbackgroundclick="true" data-dismissmodalclass="close-reveal-modal">
                <div class="reveal-modal-title">
                    <span>THÊM PHÒNG</span></div>
                <div class="reveal-modal-content">
                    <table>
                        <tr>
                            <td width="100px">
                                Số tầng:
                            </td>
                            <td>
                                <select name="sltFloorNumber" id="sltFloorNumber">
                                    <%foreach (Floor flo in lf)
                                      {%>
                                    <option value="<%=flo.PkFloorId %>">
                                        <%=flo.Name %></option>
                                    <%} %>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td width="100px">
                                Nhóm phòng:
                            </td>
                            <td>
                                <select name="sltRoomType" id="sltRoomType">
                                    <%foreach (RoomType rty in lrt)
                                      {%>
                                    <option value="<%=rty.RoomTypeId %>">
                                        <%=rty.RoomTypeName %></option>
                                    <%} %>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td width="100px">
                                Tên phòng:
                            </td>
                            <td>
                                <input type="text" width="100" name="txtRoomName" id="txtRoomName" />
                            </td>
                        </tr>
                        <tr>
                            <td width="100px">
                                Tiện nghi:
                            </td>
                            <td>
                                <input type="text" width="100" name="txtTienNghi" id="txtTienNghi" />
                            </td>
                        </tr>
                        <tr>
                            <td width="100px">
                                Thông tin phòng:
                            </td>
                            <td>
                                <input type="text" width="100" name="txtRoomInfo" id="txtRoomInfo" />
                            </td>
                        </tr>
                        <tr>
                            <td width="100px">
                                Số giường:
                            </td>
                            <td>
                                <input type="text" width="100" name="txtNoBed" id="txtNoBed" />
                            </td>
                        </tr>
                        <tr>
                            <td width="100px">
                                Số người:
                            </td>
                            <td>
                                <input type="text" width="100" name="txtNoPerson" id="txtNoPerson" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <button onclick="AddRoom();">
                                    Thêm</button>
                                <button class="close-reveal-modal">
                                    Hủy</button>
                            </td>
                        </tr>
                    </table>
                    <a class="close-reveal-modal close-reveal">
                        <img src="/Content/images/exit.png" title="exit" alt="exit" /></a>
                </div>
                <label id="lblAddRoomStatus" style="color: red;"></label>
            </div>
            <div class="box ctb">
                <div id="cuslist">
                    <div class="ltitle" id="rtitle">
                        <%--<div class="checklist">
                            <input id="chri" type="checkbox" class="chri" value="0">
                        </div>--%>
                        <div class="crname">
                            <span class="rtt" id="r_number">Phòng</span></div>
                        <div class="cequip">
                            Tiện nghi</div>
                        <div class="cequip">
                            Thông tin phòng</div>
                        <div class="cbed">
                            Số giường</div>
                        <div class="cperson">
                            Số người</div>
                        <div class="ctool">
                            Công cụ</div>
                    </div>
                    <form id="froom">
                    <%if (lr != null && lr.Count > 0)
                      {
                          for (int i = 0; i < lr.Count; i++)
                          {%>
                    <div class='<%=i%2==0?"listrow":"normal" %>' id="Div2">
                        <%--<div class="checklist">
                                    <input id="Checkbox1" name="roomid[]" type="checkbox" class="chri" value="44582">
                                </div>--%>
                        <div class="crname">
                            <strong>
                                <%=lr[i].Name %></strong></div>
                        <div class="cequip">
                            <%=lr[i].Amenities %></div>
                        <div class="cequip">
                            <%=lr[i].Information %></div>
                        <div class="cbed">
                            <%=lr[i].NoBeds %></div>
                        <div class="cperson">
                            <%=lr[i].NoPerson %></div>
                        <div class="ctool">
                            <a class="room_edit" href="#" onclick="LoadInfo('<%=lr[i].PkRoomId %>','<%=lr[i].Floor.PkFloorId %>','<%=lr[i].RoomType.RoomTypeId %>','<%=lr[i].Name %>','<%=lr[i].Amenities %>','<%=lr[i].Information %>','<%=lr[i].NoBeds %>','<%=lr[i].NoPerson %>')"
                                data-reveal-id="editRoom">Sửa</a> / <a class="room_delete" href="#" onclick="">Xóa</a></div>
                    </div>
                    <%}
                      }%>
                    <div class="l1b bb mar5">
                        <select id="movefloor" class="mar5">
                            <option value="0">Xếp theo tầng</option>
                            <%foreach (Floor flo in lf)
                              {%>
                            <option value="<%=flo.PkFloorId %>">
                                <%=flo.Name %></option>
                            <%} %>
                        </select>
                        |
                        <select id="moveroomgroup" class="mar5">
                            <option value="0">Phân loại phòng</option>
                            <%foreach (RoomType rty in lrt)
                              {%>
                            <option value="<%=rty.RoomTypeId %>">
                                <%=rty.RoomTypeName %></option>
                            <%} %>
                        </select>
                        <input id="btn-apply-floors-groups" type="button" value="Áp dụng" />
                    </div>
                    </form>
                </div>
            </div>
        </div>
        <div id="editRoom" class="reveal-modal" data-animation="none" data-animationspeed="10"
            data-closeonbackgroundclick="true" data-dismissmodalclass="close-reveal-modal">
            <div class="reveal-modal-title">
                <span>SỬA THÔNG TIN PHÒNG</span></div>
            <div class="reveal-modal-content">
                <table>
                    <tr>
                        <td width="100px">
                            Số tầng:
                        </td>
                        <td>
                            <select name="sltFloorNumber" id="sltFloorEdit">
                                <%foreach (Floor flo in lf)
                                  {%>
                                <option value="<%=flo.PkFloorId %>">
                                    <%=flo.Name %></option>
                                <%} %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td width="100px">
                            Nhóm phòng:
                        </td>
                        <td>
                            <select name="sltRoomType" id="sltRoomTypeEdit">
                                <%foreach (RoomType rty in lrt)
                                  {%>
                                <option value="<%=rty.RoomTypeId %>">
                                    <%=rty.RoomTypeName %></option>
                                <%} %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td width="100px">
                            Tên phòng:
                        </td>
                        <td>
                            <input type="text" width="100" id="txtRoomNameEdit" />
                        </td>
                    </tr>
                    <tr>
                        <td width="100px">
                            Tiện nghi:
                        </td>
                        <td>
                            <input type="text" width="100" id="txtTienNghiEdit" />
                        </td>
                    </tr>
                    <tr>
                        <td width="100px">
                            Thông tin phòng:
                        </td>
                        <td>
                            <input type="text" width="100" id="txtRoomInfoEdit" />
                        </td>
                    </tr>
                    <tr>
                        <td width="100px">
                            Số giường:
                        </td>
                        <td>
                            <input type="text" width="100" id="txtNoBedEdit" />
                        </td>
                    </tr>
                    <tr>
                        <td width="100px">
                            Số người:
                        </td>
                        <td>
                            <input type="text" width="100" id="txtNoPersonEdit" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <button onclick="EditRoom()">
                                Sửa</button>
                            <button class="close-reveal-modal">
                                Hủy</button>
                        </td>
                    </tr>
                </table>
                <input type="hidden" id="hdroomid" />
                <a class="close-reveal-modal close-reveal">
                    <img src="/Content/images/exit.png" title="exit" alt="exit" /></a>
            </div>
            <label id="lblEditRoomStatus" style="color: red;"></label>
        </div>
        <div id="roomtab_price_content" style="display: none;">
            <div class="box ttb">
                <h1>
                    <% = Resource.RoomPrice%></h1>
                <span id="selectcurrency">
                    <input type="radio" checked="checked" name="currency" id="chkvnd" />
                    <label>
                        VND</label>
                </span>
            </div>
            <div class="box ctb">
                <div id="cuslist">
                    <div class="rtitle">
                        <table width="900" border="0" cellspacing="0">
                            <tbody>
                                <tr align="right">
                                    <td class="w10 cursor" align="left">
                                        <span onclick="odbsb(&#39;r_number&#39;)">Phòng</span>
                                    </td>
                                    <td align="left">
                                        Giá theo giờ
                                    </td>
                                    <td width="290" align="left">
                                        Giá qua đêm
                                    </td>
                                    <td class="cursor" width="125">
                                        <span onclick="odbsb(&#39;p_day&#39;)">Giá theo ngày</span>
                                    </td>
                                    <td class="cursor" width="125">
                                        <span onclick="odbsb(&#39;p_week&#39;)">Giá theo tuần</span>
                                    </td>
                                    <td class="cursor" width="125">
                                        <span onclick="odbsb(&#39;p_month&#39;)">Giá theo tháng</span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div id="froompricevnd">
                        <div class="pad4">
                            <table width="906" border="0" cellspacing="0" id="tbprice">
                                <tbody>
                                    <tr class="rlistrow" align="right">
                                        <td class="w10" align="left">
                                            <b>410</b>
                                        </td>
                                        <td align="left">
                                            1h: 200,000<br>
                                            2h: 250,000<br>
                                            3h: 300,000<br>
                                            4h: 350,000<br>
                                            5h: 400,000<br>
                                            6h: 450,000<br>
                                            7h: 500,000
                                        </td>
                                        <td width="285" align="left">
                                            <b>19h00</b>: 400,000<br>
                                            <b>21h00</b>: 35,000<br>
                                            <b>23h00</b>: 300,000<br>
                                            <b>09h00</b>: 200,000<br>
                                            <b>10h00</b>: 150,000<br>
                                            <b>11h00</b>: 100,000
                                        </td>
                                        <td width="115">
                                            800,000
                                        </td>
                                        <td width="115">
                                            0
                                        </td>
                                        <td width="115">
                                            0
                                        </td>
                                    </tr>
                                    <tr class="rnormal" align="right">
                                        <td class="w10" align="left">
                                            <b>411</b>
                                        </td>
                                        <td align="left">
                                            1h: 200,000<br>
                                            2h: 250,000<br>
                                            3h: 300,000<br>
                                            4h: 350,000<br>
                                            5h: 400,000<br>
                                            6h: 450,000<br>
                                            7h: 500,000
                                        </td>
                                        <td width="285" align="left">
                                            <b>19h00</b>: 400,000<br>
                                            <b>21h00</b>: 35,000<br>
                                            <b>23h00</b>: 300,000<br>
                                            <b>09h00</b>: 200,000<br>
                                            <b>10h00</b>: 150,000<br>
                                            <b>11h00</b>: 100,000
                                        </td>
                                        <td width="115">
                                            800,000
                                        </td>
                                        <td width="115">
                                            0
                                        </td>
                                        <td width="115">
                                            0
                                        </td>
                                    </tr>
                                    
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div id="froompriceusd">
                    </div>
                </div>
            </div>
        </div>
        <div id="roomtab_setprice_content" style="display: none;">
            <form id="testingform" action="javascript:;" onsubmit="return updatePrice();">
            <input type="hidden" name="_o2bsid" value="66g0ljn5tqcjmdbnupimu53255">
            <div class="box ttb">
                <h1>
                    <% = Resource.ListOfRoom%></h1>
                <span><a id="selectallrp">Chọn tất cả | </a><a id="removeallrp">Bỏ tất cả </a></span>
            </div>
            <div class="box ctb" id="boxpricelist">
                <%--<span class="b14">Cài đặt giá cho</span>: <span class="group-name cursor" onclick="selectRoomsByGroup(0);"
                    gid="0">Chưa xếp loại</span> | <span class="group-name cursor" onclick="selectRoomsByGroup(2326);"
                        gid="2326">Deluxe</span> | <span class="group-name cursor" onclick="selectRoomsByGroup(2330);"
                            gid="2330">Double</span> | <span class="group-name cursor" onclick="selectRoomsByGroup(2340);"
                                gid="2340">Khác</span> | <span class="group-name cursor" onclick="selectRoomsByGroup(2328);"
                                    gid="2328">Standard</span> | <span class="group-name cursor" onclick="selectRoomsByGroup(2324);"
                                        gid="2324">Superiors</span>--%>
                <%--<br>
                <br>--%>
                <% foreach (var room in lr)
                   {%>
                <div class="rp">
                    <input gid="2326" id="chk<%=room.PkRoomId %>" name="roomid[]" type="checkbox" class="chk" value="<%=room.PkRoomId %>"><label><%=room.Name %></label>
                    <%RoomPrice rp = Hotel.Models.Services.RoomPriceService.GetRoomPriceDetail(room.PkRoomId);
                      if (rp != null)
                      { %>
                    <a class="fillprice-trigger cursor" onclick="fillprice('<%=room.PkRoomId %>','<%=rp.OneHours %>','<%=rp.DayPrice %>','<%=rp.DayWeek %>','<%=rp.DayMonth %>','<%=rp.Overnight %>','<%=rp.PersonMore %>','<%=rp.MoneyMore %>','<%=rp.MoneyMoreNext %>')">
                        xem / sửa</a>
                        <%}
                      else {%> 
                      <a class="fillprice-trigger cursor" onclick="selectCheckbox('<%=room.PkRoomId %>');" >
                        xem / sửa</a>
                      <%} %>
                </div>
                <%} %>
                
            </div>
            <div class="box ttb">
                <h1>
                    Áp dụng giá</h1>
                <span class="lr"><a href="#"
                    target="_blank">
                    <img height="18" src="/Content/images/help.png">
                    Hướng dẫn cài đặt tính tiền</a></span>
            </div>
            <div class="box ctb" id="prtb">
                <div class="priceset-left">
                    <div class="cphour tt">
                        Theo giờ</div>
                    <div class="cphour" id="listvn">
                        <div class="cphour">
                            <input type="text" class="txt1" name="hour[]" maxlength="2" id="txtRoomPriceHour1"><span>Giờ</span><input
                                type="text" class="txt2" name="hourprice[]" maxlength="9" id="txtRoomPrice1"><span> VND </span>
                            <div id="btnAdd">
                                <a href="javascript:;" onclick="addHourPrice();" class="ladd">
                                    <div class="icAdd">
                                    </div>
                                    THÊM</a></div>
                        </div>
                    </div>
                    
                </div>
                <div class="priceset-center">
                    <div class="cpday tt">
                        Theo ngày</div>
                    <div class="cpday">
                        <input type="text" class="txt2" id="txtdayprice" name="dayprice" maxlength="11">
                        <span>(VND)</span></div>
                    <div class="cpweek tt">
                        Theo tuần</div>
                    <div class="cpweek">
                        <input type="text" class="txt2" id="txtweekprice" name="weekprice" maxlength="12"><span>
                            (VND)</span></div>
                    <div class="cpmonth tt">
                        Theo tháng</div>
                    <div class="cpmonth">
                        <input type="text" class="txt2" id="txtmonthprice" name="monthprice" maxlength="12">
                        <span>(VND)</span></div>
                    <div class="cpday tt">
                        Qua đêm</div>
                    <div class="cpday">
                        <input type="text" class="txt2" id="txtprice_p_night" name="price_p_night" maxlength="11">
                        <span>(VND)</span></div>
                </div>
                <div class="priceset-right">
                    <div class="tt">
                        Theo số người</div>
                    <div id="listcustvn">
                        <div class="custcostrow">
                            <span>Thêm</span>
                            <input class="txt1" name="numcustvn[]" id="txtNumberPersonMore" maxlength="2">
                            <span>người, cộng</span>
                            <input type="text" class="txt2" name="custcostvn[]" maxlength="9" id="txtPricePersonMore">
                            <span>VND (%)/người</span>
                            <div id="btnAddCustCost">
                                <a href="javascript:;" onclick="addCustCost();" class="ladd">
                                    <div class="icAdd">
                                    </div>
                                    THÊM</a></div>
                        </div>
                    </div>
                    <span>Cộng thêm</span>
                    <input type="text" name="othercustcostvn" maxlength="9" class="txt2" id="txtPricePersonMoreNext">
                    <span>VND (%) / người cho những người tiếp theo</span>
                </div>
                <br style="clear: both">
                <div class="sm">
                    <span class="btsm">
                        <div class="sml">
                        </div>
                        <a href="javascript:;" class="smc" onclick="updatePrice();">Cập nhật các phòng đã chọn</a><div
                            class="smr">
                        </div>
                    </span>
                </div>
            </div>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        //                    $(document).ready(function () {
        //                        function getNum(element, attrPrefix) {
        //                            //set prefix, get number
        //                            var prefix = attrPrefix;
        //                            var num = element.attr("id").substring((prefix.length));
        //                            return num;
        //                        }
        //                        $(document).on("click", "a.editFloor", function () {
        //                            var num = getNum($(this), "fname");
        //                            // alert($("#lblfloor" + num));
        //                            var txt = $("label#lblfloor" + num).text();
        //                            $("label#lblfloor" + num).replaceWith("<input maxlength='100' class='txtfname'" + "id=txtFname" + num + " style='float: left; width: 90px'/>");
        //                            $("input#txtFname" + num).val(txt);
        //                        });

        //                        $(document).on("blur", "input.txtfname", function () {
        //                            var num = getNum($(this), "txtFname");
        //                            var txt = $(this).val();
        //                            $(this).replaceWith("<label class='lblfloor" + num + "' id='lblfloor" + num + "'" + "></label>");
        //                            $(".lblfloor" + num).text(txt);
        setTimeout("CallButton()", 1000);
        function CallButton() {
            document.getElementById("rt_info").click();
        }

        function EditFloor(id) {

            $(".boxfname").hide();
            $(".lblfloor").show();
            var name = $("#txtfname" + id).val().trim();
            if (name == "") {
                $("#messagetitle").text("Vui lòng nhập tên Lầu");
                $(".close-reveal-modal").click();
                $("#amessage").click();
                return false;
            }
            $("#lblfloor" + id).text(name);
            $.ajax({
                type: "POST",
                url: '/Room/EditFloor',
                data: {
                    id: id,
                    name: name
                },

                success: function (data) {
                    //alert('cannot Find  resource');
                    $("#lblfloor" + id).val(name);
                },
                statusCode: {
                    404: function (content) {
                        //alert('cannot Find  resource');
                    },
                    505: function (content) {

                        // alert('internal server error');
                    },
                    200: function (data) {

                        // alert('server found');
                    },

                    500: function (content) {

                        //alert('Error found');
                    }
                },

                error: function (req, status, errorObj) {
                    alert('time out');
                }

            });
            return true;
        }

        function editFloor(id) {
            $(".boxfname").hide();
            $(".lblfloor").show();
            $("#boxfname" + id).show();
            $("#txtfname" + id).select();
            $("#txtfname" + id).focus();
            $("#lblfloor" + id).hide();
        }
        function editRoomType(id) {
            $(".boxgname").hide();
            $(".lblgname").show();
            $("#boxgname" + id).show();
            $("#txtRoomTypeName" + id).select();
            $("#txtRoomTypeName" + id).focus();
            $("#lblRoomTypeName" + id).hide();
        }

        function AddFloor() {
            var name = $("#txtFloorName").val().trim();
            if (name == "") {
                $("#lblAddFloorStatus").text("Vui lòng nhập tên Lầu");
               
                return false;
            }
            $.ajax({
                type: "POST",
                url: '/Room/AddFloor',
                data: {
                    name: name
                },

                success: function (data) {
                    //alert('cannot Find  resource');
                    //$("#lblfloor" + id).val(name);
                    window.location = "/Room/Room";
                },
                statusCode: {
                    404: function (content) {
                        //alert('cannot Find  resource');
                    },
                    505: function (content) {

                        // alert('internal server error');
                    },
                    200: function (data) {

                        // alert('server found');
                    },

                    500: function (content) {

                        //alert('Error found');
                    }
                },

                error: function (req, status, errorObj) {
                    alert('time out');
                }

            });
            return true;
        }

        function AddRoomType() {
            var name = $("#txtRoomTypeName").val().trim();
            if (name == "") {
                $("#lblAddRoomTypeStatus").text("Vui lòng nhập tên loại phòng");
                
                return false;
            }
            $.ajax({
                type: "POST",
                url: '/Room/AddRoomType',
                data: {
                    name: name
                },

                success: function (data) {
                    //alert('cannot Find  resource');
                    //$("#lblfloor" + id).val(name);
                    window.location = "/Room/Room";
                },
                statusCode: {
                    404: function (content) {
                        //alert('cannot Find  resource');
                    },
                    505: function (content) {

                        // alert('internal server error');
                    },
                    200: function (data) {

                        // alert('server found');
                    },

                    500: function (content) {

                        //alert('Error found');
                    }
                },

                error: function (req, status, errorObj) {
                    alert('time out');
                }

            });
            return true;
        }

        function EditRoomType(id) {

            $(".boxgname").hide();
            $(".lblgname").show();
            var name = $("#txtRoomTypeName" + id).val().trim();
            if (name == "") {
                $("#messagetitle").text("Vui lòng nhập tên loại phòng");
                $(".close-reveal-modal").click();
                $("#amessage").click();
                return false;
            }
            $("#lblRoomTypeName" + id).text(name);
            $.ajax({
                type: "POST",
                url: '/Room/EditRoomType',
                data: {
                    id: id,
                    name: name
                },

                success: function (data) {
                    //alert('cannot Find  resource');
                    $("#lblRoomTypeName" + id).val(name);
                },
                statusCode: {
                    404: function (content) {
                        //alert('cannot Find  resource');
                    },
                    505: function (content) {

                        // alert('internal server error');
                    },
                    200: function (data) {

                        // alert('server found');
                    },

                    500: function (content) {

                        //alert('Error found');
                    }
                },

                error: function (req, status, errorObj) {
                    alert('time out');
                }

            });
            return true;
        }

        function LoadInfo(id, floorid, roomtypeid, name, tiennghi, info, nobed, noperson) {
            $("#sltFloorEdit").val(floorid);
            $("#sltRoomTypeEdit").val(roomtypeid);
            $("#txtRoomNameEdit").val(name);
            $("#txtTienNghiEdit").val(tiennghi);
            $("#txtRoomInfoEdit").val(info);
            $("#txtNoBedEdit").val(nobed);
            $("#txtNoPersonEdit").val(noperson);
            $("#hdroomid").val(id);
        }

        function AddRoom() {
            var name = $("#txtRoomName").val().trim();
            var tiennghi = $("#txtTienNghi").val().trim();
            var info = $("#txtRoomInfo").val().trim();
            var nobed = $("#txtNoBed").val().trim();
            var noperson = $("#txtNoPerson").val().trim();
            var floor = $("#sltFloorNumber").val();
            var roomtype = $("#sltRoomType").val();
            if (name == "") {
                $("#lblAddRoomStatus").text("Vui lòng nhập tên loại phòng");
                
                return false;
            }
            else if (nobed == "") {
                $("#lblAddRoomStatus").text("Vui lòng nhập số giường");
                
                return false;
            }
            else if (noperson == "") {
                $("#lblAddRoomStatus").text("Vui lòng nhập số người");
                
                return false;
            }
            $.ajax({
                type: "POST",
                url: '/Room/AddRoom',
                data: {
                    floorId: floor,
                    roomTypeId: roomtype,
                    name: name,
                    amenities: tiennghi,
                    information: info,
                    noBed: nobed,
                    noPerson: noperson
                },

                success: function (data) {
                    //alert('cannot Find  resource');
                    //$("#lblfloor" + id).val(name);
                    window.location = "/Room/Room";
                },
                statusCode: {
                    404: function (content) {
                        //alert('cannot Find  resource');
                    },
                    505: function (content) {

                        // alert('internal server error');
                    },
                    200: function (data) {

                        // alert('server found');
                    },

                    500: function (content) {

                        //alert('Error found');
                    }
                },

                error: function (req, status, errorObj) {
                    alert('time out');
                }

            });
            return true;
        }

        function EditRoom() {
            var id = $("#hdroomid").val();
            var name = $("#txtRoomNameEdit").val().trim();
            var tiennghi = $("#txtTienNghiEdit").val().trim();
            var info = $("#txtRoomInfoEdit").val().trim();
            var nobed = $("#txtNoBedEdit").val().trim();
            var noperson = $("#txtNoPersonEdit").val().trim();
            var floor = $("#sltFloorEdit").val();
            var roomtype = $("#sltRoomTypeEdit").val();
            if (name == "") {
                $("#lblEditRoomStatus").text("Vui lòng nhập tên loại phòng");
                return false;
            }
            else if (nobed == "") {
                $("#lblEditRoomStatus").text("Vui lòng nhập số giường");
                return false;
            }
            else if (noperson == "") {
                $("#lblEditRoomStatus").text("Vui lòng nhập số người");
                return false;
            }
            $.ajax({
                type: "POST",
                url: '/Room/EditRoom',
                data: {
                    id: id,
                    floorId: floor,
                    roomTypeId: roomtype,
                    name: name,
                    amenities: tiennghi,
                    information: info,
                    noBed: nobed,
                    noPerson: noperson
                },

                success: function (data) {
                    //alert('cannot Find  resource');
                    //$("#lblfloor" + id).val(name);
                    window.location = "/Room/Room";
                },
                statusCode: {
                    404: function (content) {
                        //alert('cannot Find  resource');
                    },
                    505: function (content) {

                        // alert('internal server error');
                    },
                    200: function (data) {

                        // alert('server found');
                    },

                    500: function (content) {

                        //alert('Error found');
                    }
                },

                error: function (req, status, errorObj) {
                    alert('time out');
                }

            });
            return true;
        }
        $("#selectallrp").click(function () {
            $("input.chk").prop("checked", true);
        });
        $("#removeallrp").click(function () {
            $("input.chk").prop("checked", false);
        });
        function fillprice(roomID, OneHours, DayPrice, DayWeek, DayMonth, Overnight, PersonMore, MoneyMore, MoneyMoreNext) {
            $("input.chk").prop("checked", false);
            $("input#chk" + roomID).prop("checked", true);
            $("#txtRoomPriceHour1").val(1);
            $("#txtRoomPrice1").val(OneHours);
            $("#txtdayprice").val(DayPrice);
            $("#txtweekprice").val(DayWeek);
            $("#txtmonthprice").val(DayMonth);
            $("#txtprice_p_night").val(Overnight);
            $("#txtNumberPersonMore").val(PersonMore);
            $("#txtPricePersonMore").val(MoneyMore);
            $("#txtPricePersonMoreNext").val(MoneyMoreNext);
        }
        function selectCheckbox(roomID) {
            $("input.chk").prop("checked", false);
            $("input#chk" + roomID).prop("checked", true);
            $("#txtRoomPriceHour1").val(1);
            $("#txtRoomPrice1").val(0);
            $("#txtdayprice").val(0);
            $("#txtweekprice").val(0);
            $("#txtmonthprice").val(0);
            $("#txtprice_p_night").val(0);
            $("#txtNumberPersonMore").val(0);
            $("#txtPricePersonMore").val(0);
            $("#txtPricePersonMoreNext").val(0);
        }
    </script>
</asp:Content>
